package UnitTest;

import java.util.concurrent.TimeUnit;

/**
 * @Auther: Administrator
 * @Date: 2019/12/8/008 21 14
 * @Description:
 */
public class Interrupted {
    public static void main(String[] args) throws Exception {
        Thread sleepThread = new Thread(new SleepThread(), "SleepThread");
        sleepThread.setDaemon(true);
        Thread busyThread = new Thread(new BusyThread(), "BusyThread");
        busyThread.setDaemon(true);
        sleepThread.start();
        busyThread.start();
        TimeUnit.SECONDS.sleep(5);
        sleepThread.interrupt();
        busyThread.interrupt();
        TimeUnit.SECONDS.sleep(2);
        System.out.println("sleepThread"+sleepThread.isInterrupted());
        System.out.println("busyThread"+busyThread.isInterrupted());
    }

    static class SleepThread implements Runnable{
        @Override
        public void run() {
            while (true){
                SleepUtils.second(100l);
            }
        }
    }

    static class BusyThread implements Runnable {
        @Override
        public void run() {
            while (true){

            }
        }
    }
}


